<template>
  <div class="body">
    <div class="header">
      <div class="background_url">
        <img :src="firstChapter.coverUrl" alt="" />
      </div>
      <div class="icon" @click="close">
        <img src="./img/guanbi.png" alt="" />
      </div>
      <div class="title">Fish Novel</div>
      <div class="img">
        <img :src="firstChapter.coverUrl" alt="" />
      </div>
    </div>
    <div class="Dataname">
      <div class="top">{{ firstChapter.bookTitle }}</div>
      <div class="buttom">{{ firstChapter.authorName }}</div>
    </div>
    <div
      :class="is_display == false ? 'Dataintroduction_on' : 'Dataintroduction'"
    >
      <div class="text">
        {{ firstChapter.bookIntro }}
        <div class="icon" @click="nihao">
          <img src="./img/xialama.png" alt="" />
        </div>
      </div>

      <div class="Chaptername">{{ firstChapter.firstChapterName }}</div>
      <div class="Chaptercontent">
        {{ firstChapter.firstChapterContent }}
      </div>
    </div>
    <div class="button">Read Now</div>
  </div>
</template>
<script src="./flexible.js"></script>
<script>
import { bookDetailsH5 } from "@/api/info";
export default {
  data() {
    return {
      is_display: true,
      bookId: "E1382209329755197440",
      firstChapter: [],
    };
  },
  methods: {
    nihao() {
      this.is_display = !this.is_display;
    },
    //关闭H5页面
    close() {
      var userAgent = navigator.userAgent;
      if (
        userAgent.indexOf("Firefox") != -1 ||
        userAgent.indexOf("Chrome") != -1
      ) {
        window.location.href = "about:blank";
      } else if (
        userAgent.indexOf("Android") > -1 ||
        userAgent.indexOf("Linux") > -1
      ) {
        window.opener = null;
        window.open("about:blank", "_self", "").close();
      } else {
        window.opener = null;
        window.open("about:blank", "_self");
        window.close();
      }
    },
    //H5详情页数据
    bookDetailsH5() {
      bookDetailsH5({ bookId: this.bookId }).then(
        (res) => {
          if (res.data.code == 1) {
            this.firstChapter = res.data.source;
          }
        },
        (fail) => {
          console.log(fail);
        }
      );
    },
  },
  created() {
    this.bookId = this.$route.query.bookId;
    if (this.bookId != null || this.bookId != undefined) {
      // H5详情页数据
      this.bookDetailsH5();
    }
  },
  mounted() {},
  computed: {},
};
</script>
<style lang="scss" scoped>
.body {
  width: 100%;
  height: 100%;
  position: relative;
  .header {
    width: auto;
    height: 4.4rem;
    position: relative;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(134, 134, 125, 0.7);
    .background_url {
      img {
        width: 100%;
        height: 4.4rem;
        -webkit-filter: blur(0px);
        filter: blur(5px);
      }
    }
    .icon {
      width: 0.36rem;
      height: 0.42rem;
      position: absolute;
      top: 1.2rem;
      left: 0.07rem;
      // img {
      //   width: 100%;
      //   height: auto;
      // }
    }
    .title {
      height: 0.36rem;
      position: absolute;
      top: 1.2rem;
      left: 2.84rem;
      font-size: 0.36rem;
      line-height: 0.36rem;
      text-align: center;
      color: #ffffff;
      font-weight: bold;
    }
    .img {
      height: 3.34rem;
      position: absolute;
      top: 2.06rem;
      left: 2.52rem;
      img {
        width: 100%;
        height: 100%;
        border-radius: 0.12rem;
      }
    }
  }
  .Dataname {
    width: 5.16rem;
    height: 1.26rem;
    position: absolute;
    top: 5.72rem;
    left: 1.18rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    text-align: center;
    .top {
      width: 100%;
      height: 0.78rem;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      font-size: 0.3rem;
      font-weight: bold;
    }
    .buttom {
      width: 0.9rem;
      height: 0.2rem;
      font-size: 0.2rem;
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;
      line-height: 0.2rem;
      color: #999999;
    }
  }
  .Dataintroduction {
    width: 6.94rem;
    height: 1.78rem;
    position: absolute;
    top: 7.48rem;
    left: 0.24rem;
    color: #999999;
    .text {
      font-size: 0.3rem;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 4;
      -webkit-box-orient: vertical;
      position: relative;
      .icon {
        width: 0.22rem;
        height: 0.22rem;
        position: absolute;
        bottom: 0rem;
        right: 0rem;
        line-height: 0.22rem;
        img {
          position: absolute;
          bottom: 0rem;
          right: 0rem;
        }
      }
    }
    .Chaptername {
      width: 6rem;
      height: 0.34rem;
      color: #333333;
      font-size: 0.34rem;
      line-height: 0.34rem;
      font-weight: bold;
      margin-top: 0.64rem;
    }
    .Chaptercontent {
      width: 6.88rem;
      height: auto;
      font-size: 0.32rem;
      margin-top: 0.32rem;
    }
  }
  .Dataintroduction_on {
    width: 6.94rem;
    position: absolute;
    top: 7.48rem;
    left: 0.24rem;
    color: #999999;
    font-size: 0.3rem;
    .text {
      position: relative;
      .icon {
        width: 0.22rem;
        height: 0.22rem;
        position: absolute;
        bottom: 0rem;
        right: 0rem;
      }
      img {
        position: absolute;
        bottom: 0rem;
        right: 0rem;
      }
    }

    .Chaptername {
      width: 6rem;
      height: 0.34rem;
      color: #333333;
      font-size: 0.34rem;
      line-height: 0.34rem;
      font-weight: bold;
      margin-top: 0.64rem;
    }
    .Chaptercontent {
      width: 6.88rem;
      height: auto;
      font-size: 0.32rem;
      margin-top: 0.32rem;
    }
  }
  .button {
    width: 6.02rem;
    height: 0.98rem;
    background: #e86472;
    border-radius: 0.1rem;
    position: fixed;
    bottom: 0.2rem;
    z-index: 1;
    left: 0.76rem;
    color: #ffffff;
    font-size: 0.27rem;
    text-align: center;
    line-height: 0.98rem;
  }
}
</style>